package com.linkgie.galaxyframework.httpproxy.core;

import com.linkgie.galaxyframework.httpproxy.HttpRequestDefinition;
import com.linkgie.galaxyframework.httpproxy.ResponseConverter;
import com.linkgie.galaxyframework.httpproxy.ResponseConverterFactory;
import com.linkgie.galaxyframework.httpproxy.converters.ByteArrayResponseConverter;
import com.linkgie.galaxyframework.httpproxy.converters.JsonResponseConverter;
import com.linkgie.galaxyframework.httpproxy.converters.StringResponseConverter;

@Deprecated
public class DefaultResponseConverterFactory implements ResponseConverterFactory {
	
	public static final DefaultResponseConverterFactory INSTANCE = new DefaultResponseConverterFactory();
	
	private DefaultResponseConverterFactory() {
	}

	@Override
	public ResponseConverter createResponseConverter(HttpRequestDefinition requestDefinition, Class<?> returnType) {
		// create default response converter;
		if (byte[].class == returnType) {
			return ByteArrayResponseConverter.INSTANCE;
		}
		if (String.class == returnType) {
			return StringResponseConverter.INSTANCE;
		}
		
		// TODO:未处理 基本类型、输入输出流；
		return new JsonResponseConverter(returnType);
	}

}
